var img =document.querySelectorAll('.pay-way img')
console.log(img);
var cos =document.querySelector('.cos')
var span=document.querySelector('.mask span')
for (let i = 0; i < img.length; i++) {
    img[i].onclick =function(){
    cos.style.display ='block'
}
}
span.onclick=function(){
    cos.style.display ='none'
} 
var list = JSON.parse(localStorage.getItem('cart')) || []
console.log(list);
var pay =document.querySelector('.pay')
var num = 0
var price = 0
list.forEach(item=>{
    if(item.is_select == true){
        num+=item.cart_number
        price+=item.price * item.cart_number
    }
    pay.innerHTML = price+'元'
})
// 退出登录
let exit =document.querySelector('.exit')
let login = document.querySelector('#login_a')
if(localStorage.getItem('username') ){
    login.innerHTML ="您已登录"
    exit.style.display='inline-block'
}
console.log(exit);
exit.onclick = function(){
    console.log(1);
    localStorage.removeItem('username')
  localStorage.removeItem('pass')
  login.innerHTML="登录" 
  exit.style.displa ="none"
}
login.onclick =function(){
    if (!localStorage.getItem('username')) {
        location.href="http://localhost:2205/html/login.html"
    }
}